﻿using System;
using Metaspec;

class MyAstVisitor : ICsAstVisitor
{
	public void visit(CsExternAliasDirective node) { visitCsNode(node); }
	public void visit(CsUsingAliasDirective node) { visitCsNode(node); }
	public void visit(CsUsingNamespaceDirective node) { visitCsNode(node); }
	public void visit(CsTypeRef node) { visitCsNode(node); }
	public void visit(CsTypeArgumentList node) { visitCsNode(node); }
	public void visit(CsQualifiedAliasMember node) { visitCsNode(node); }
	public void visit(CsNamespaceOrTypeName node) { visitCsNode(node); }
	public void visit(CsSimpleName node) { visitCsNode(node); }
	public void visit(CsLiteral node) { visitCsNode(node); }
	public void visit(CsPredefinedTypeMemberAccess node) { visitCsNode(node); }
	public void visit(CsThisAccess node) { visitCsNode(node); }
	public void visit(CsBaseMemberAccess node) { visitCsNode(node); }
	public void visit(CsBaseIndexerAccess node) { visitCsNode(node); }
	public void visit(CsTypeofExpression node) { visitCsNode(node); }
	public void visit(CsCheckedExpression node) { visitCsNode(node); }
	public void visit(CsUncheckedExpression node) { visitCsNode(node); }
	public void visit(CsLockStatement node) { visitCsNode(node); }
	public void visit(CsSizeofExpression node) { visitCsNode(node); }
	public void visit(CsParenthesizedExpression node) { visitCsNode(node); }
	public void visit(CsMemberInitializer node) { visitCsNode(node); }
	public void visit(CsObjectInitializer node) { visitCsNode(node); }
	public void visit(CsCollectionInitializer node) { visitCsNode(node); }
	public void visit(CsNewObjectExpression node) { visitCsNode(node); }
	public void visit(CsNewArrayExpression node) { visitCsNode(node); }
	public void visit(CsMemberDeclarator node) { visitCsNode(node); }
	public void visit(CsAnonymousObjectCreationExpression node) { visitCsNode(node); }
	public void visit(CsInvocationExpression node) { visitCsNode(node); }
	public void visit(CsElementAccess node) { visitCsNode(node); }
	public void visit(CsPrimaryExpressionMemberAccess node) { visitCsNode(node); }
	public void visit(CsPointerMemberAccess node) { visitCsNode(node); }
	public void visit(CsPostIncrementDecrementExpression node) { visitCsNode(node); }
	public void visit(CsBinaryExpression node) { visitCsNode(node); }
	public void visit(CsAsIsExpression node) { visitCsNode(node); }
	public void visit(CsConditionalExpression node) { visitCsNode(node); }
	public void visit(CsOperatorUnaryExpression node) { visitCsNode(node); }
	public void visit(CsPreIncrementDecrementExpression node) { visitCsNode(node); }
	public void visit(CsCastUnaryExpression node) { visitCsNode(node); }
	public void visit(CsAssignmentExpression node) { visitCsNode(node); }
	public void visit(CsQualifiedAliasMemberAccess node) { visitCsNode(node); }
	public void visit(CsDefaultValueExpression node) { visitCsNode(node); }
	public void visit(CsAnonymousMethodExpression node) { visitCsNode(node); }
	public void visit(CsExpressionList node) { visitCsNode(node); }
	public void visit(CsPositionalArgumentList node) { visitCsNode(node); }
	public void visit(CsElementInitializer node) { visitCsNode(node); }
	public void visit(CsLambdaExpression node) { visitCsNode(node); }
	public void visit(CsJoinClause node) { visitCsNode(node); }
	public void visit(CsFromClause node) { visitCsNode(node); }
	public void visit(CsLetClause node) { visitCsNode(node); }
	public void visit(CsWhereClause node) { visitCsNode(node); }
	public void visit(CsOrdering node) { visitCsNode(node); }
	public void visit(CsOrderbyClause node) { visitCsNode(node); }
	public void visit(CsSelectClause node) { visitCsNode(node); }
	public void visit(CsGroupClause node) { visitCsNode(node); }
	public void visit(CsQueryContinuation node) { visitCsNode(node); }
	public void visit(CsQueryBody node) { visitCsNode(node); }
	public void visit(CsQueryExpression node) { translateQueryExpression(node); }
	public void visit(CsNamedArgument node) { visitCsNode(node); }
	public void visit(CsAttribute node) { visitCsNode(node); }
	public void visit(CsAttributeSection node) { visitCsNode(node); }
	public void visit(CsAttributes node) { visitCsNode(node); }
	public void visit(CsTypeBase node) { visitCsNode(node); }
	public void visit(CsTypeParameter node) { visitCsNode(node); }
	public void visit(CsTypeParameterList node) { visitCsNode(node); }
	public void visit(CsTypeParameterConstraintsClause node) { visitCsNode(node); }
	public void visit(CsClass node) { visitCsNode(node); }
	public void visit(CsStruct node) { visitCsNode(node); }
	public void visit(CsInterface node) { visitCsNode(node); }
	public void visit(CsEnumMember node) { visitCsNode(node); }
	public void visit(CsEnum node) { visitCsNode(node); }
	public void visit(CsDefaultArgument node) { visitCsNode(node); }
	public void visit(CsFormalParameter node) { visitCsNode(node); }
	public void visit(CsFormalParameterList node) { visitCsNode(node); }
	public void visit(CsAnonymousFunctionSignature node) { visitCsNode(node); }
	public void visit(CsDelegate node) { visitCsNode(node); }
	public void visit(CsNamespace node) { visitCsNode(node); }
	public void visit(CsArgumentName node) { visitCsNode(node); }
	public void visit(CsArgument node) { visitCsNode(node); }
	public void visit(CsArgumentList node) { visitCsNode(node); }
	public void visit(CsBlock node) { visitCsNode(node); }
	public void visit(CsLabel node) { visitCsNode(node); }
	public void visit(CsLabeledStatement node) { visitCsNode(node); }
	public void visit(CsEmptyStatement node) { visitCsNode(node); }
	public void visit(CsExpressionStatement node) { visitCsNode(node); }
	public void visit(CsDeclarationStatement node) { visitCsNode(node); }
	public void visit(CsLocalConstantDeclarator node) { visitCsNode(node); }
	public void visit(CsLocalConstantDeclaration node) { visitCsNode(node); }
	public void visit(CsIfStatement node) { visitCsNode(node); }
	public void visit(CsSwitchLabel node) { visitCsNode(node); }
	public void visit(CsSwitchSection node) { visitCsNode(node); }
	public void visit(CsSwitchStatement node) { visitCsNode(node); }
	public void visit(CsWhileStatement node) { visitCsNode(node); }
	public void visit(CsDoWhileStatement node) { visitCsNode(node); }
	public void visit(CsLocalVariableDeclarator node) { visitCsNode(node); }
	public void visit(CsLocalVariableDeclaration node) { visitCsNode(node); }
	public void visit(CsStatementExpressionList node) { visitCsNode(node); }
	public void visit(CsForStatement node) { visitCsNode(node); }
	public void visit(CsForeachStatement node) { visitCsNode(node); }
	public void visit(CsBreakStatement node) { visitCsNode(node); }
	public void visit(CsContinueStatement node) { visitCsNode(node); }
	public void visit(CsGotoStatement node) { visitCsNode(node); }
	public void visit(CsReturnStatement node) { visitCsNode(node); }
	public void visit(CsThrowStatement node) { visitCsNode(node); }
	public void visit(CsCatchClause node) { visitCsNode(node); }
	public void visit(CsTryStatement node) { visitCsNode(node); }
	public void visit(CsCheckedStatement node) { visitCsNode(node); }
	public void visit(CsUncheckedStatement node) { visitCsNode(node); }
	public void visit(CsUsingStatement node) { visitCsNode(node); }
	public void visit(CsUnsafeStatement node) { visitCsNode(node); }
	public void visit(CsFixedPointDeclarator node) { visitCsNode(node); }
	public void visit(CsFixedStatement node) { visitCsNode(node); }
	public void visit(CsYieldStatement node) { visitCsNode(node); }
	public void visit(CsStackAllocInitializer node) { visitCsNode(node); }
	public void visit(CsConstructor node) { visitCsNode(node); }
	public void visit(CsConstantDeclarator node) { visitCsNode(node); }
	public void visit(CsConstantDeclaration node) { visitCsNode(node); }
	public void visit(CsVariableDeclarator node) { visitCsNode(node); }
	public void visit(CsVariableDeclaration node) { visitCsNode(node); }
	public void visit(CsArrayInitializer node) { visitCsNode(node); }
	public void visit(CsMethod node) { visitCsNode(node); }
	public void visit(CsPropertyAccessor node) { visitCsNode(node); }
	public void visit(CsProperty node) { visitCsNode(node); }
	public void visit(CsEventAccessor node) { visitCsNode(node); }
	public void visit(CsEventDeclarator node) { visitCsNode(node); }
	public void visit(CsEvent node) { visitCsNode(node); }
	public void visit(CsIndexer node) { visitCsNode(node); }
	public void visit(CsOperator node) { visitCsNode(node); }
	public void visit(CsConversionOperator node) { visitCsNode(node); }
	public void visit(CsDestructor node) { visitCsNode(node); }
	public void visit(CsCompilationUnit node) { visitCsNode(node); }
	public void visit(CsMakeRefExpression node) { visitCsNode(node); }
	public void visit(CsRefTypeExpression node) { visitCsNode(node); }
	public void visit(CsRefValueExpression node) { visitCsNode(node); }
	public void visit(CsArgListExpression node) { visitCsNode(node); }
	public void visit(CsFixedSizeBufferDeclarator node) { visitCsNode(node); }
	public void visit(CsFixedSizeBuffer node) { visitCsNode(node); }

	public void visitCsNode(CsNode node)
	{
	}

	void translateQueryExpression(CsQueryExpression expr)
	{
		CsFormatter formatter = new CsFormatter();
		
		formatter.generate(expr);
		string linqText = formatter.getGeneratedText();

		Console.WriteLine("Linq:");
		Console.WriteLine("");
		Console.WriteLine(linqText);
		Console.WriteLine("");

		formatter.generate(expr.translated_expression);
		string translatedText = formatter.getGeneratedText();

		Console.WriteLine("Translated:");
		Console.WriteLine("");
		Console.WriteLine(translatedText);
		Console.WriteLine("");
	}
}